package br.ufrj.ppgi.greco;

import java.util.ArrayList;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.RectF;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;

public class PlacesOverlay extends Overlay
{
	//private GeoPoint geoPoint;
	private ArrayList<Ponto> pontos; 

	
	// construtor da classe de Overlay para os pontos que serão cadastrados
	public PlacesOverlay(ArrayList<Ponto> p)
	{		
		this.pontos = p;
	}

	
	
	
	@Override
	public void draw(Canvas canvas, MapView mapView, boolean shadow)
	{
		super.draw(canvas, mapView, shadow);

		Bitmap bitmap = BitmapFactory.decodeResource(mapView.getResources(),R.drawable.hotel);
		Paint paint = new Paint();
				
		for(Ponto ponto : this.pontos)
		{
			Point p = mapView.getProjection().toPixels(ponto.getGp(),null);
			RectF r = new RectF(p.x,p.y,p.x+bitmap.getWidth(), p.y+bitmap.getHeight());
			canvas.drawBitmap(bitmap, null,r,paint);
		}
		
		
	}
	
	
	
	@Override
	public boolean onTap(GeoPoint geoPoint,MapView mapView)
	{	
		
		
		
		
		
		Point p = mapView.getProjection().toPixels(geoPoint,null);
			
		Intent intent = new Intent(mapView.getContext() , br.ufrj.ppgi.greco.ActivityTeste.class);
		
		intent.putExtra("ENTRADA", "Maria");
		
		intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 

		mapView.getContext().startActivity(intent);
		
		return true;
	}
	

}
